package gui;

import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.JPanel;

public class GameMap extends JPanel{
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	private static int tileColumns;
	private static int tileRows;
	ImageLabel[][] map;
	GameMap(int windowWidth, int windowHeight){
		map.Map gameMap = new map.Map(100);
		gameMap.generateTerrain();
		
		tileColumns = windowHeight/32;
		tileRows = windowWidth/32;
		setLayout(null);
		map = new ImageLabel[tileColumns][tileRows];
		for(int x = 0; x < tileColumns; x++){
			for(int y = 0; y < tileRows; y++){
				map[x][y] = new ImageLabel("resources/images/grass1.png");
				map[x][y].setBounds(x*32, y*32, 32, 32);
				add(map[x][y]);
			}
		}
		addKeyListener(new KeyListener() {
			
			@Override
			public void keyTyped(KeyEvent arg0) {
				//if(arg0.getKeyCode() )
				
			}
			
			@Override
			public void keyReleased(KeyEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void keyPressed(KeyEvent arg0) {
				// TODO Auto-generated method stub
				
			}
		});
	}
	public void addPlayer(Player player){
		int[] playerPosition = player.getPosition();
		map[playerPosition[0]][playerPosition[1]].changeImage("resources/images/water.png");
		
	}
	public void updateMap(){
		for(int count = 0; count < tileColumns; count++){
			for(int count1 = 0; count1 < tileRows; count1++){
				map[count][count1].changeImage("resources/images/grass1.png");
			}
		}
		
	}
}
